-
Notifications
You must be signed in to change notification settings - Fork 862
[EuiSuperDatePicker] Time zone display #9191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/super-date-picker-track-1-ms-1
Are you sure you want to change the base?
[EuiSuperDatePicker] Time zone display #9191
Conversation
💚 Build SucceededHistory
cc @acstll |
💚 Build Succeeded
History
cc @acstll |
| * @example "America/Los_Angeles" | ||
| * @link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | ||
| */ | ||
| timeZoneDisplay?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a simple string, the naming display doesn't quite fit, imho.
The component already is called EuiTimeZoneDisplay, how about just naming it timeZone?
And drilled props could then be timeZone and timeZoneCustomRender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind about drilled props that much, having them named the same has to do also with "types saving" (if that makes sense 😁)
the display part was intentional, to make it clear it's something informational and it's not going to affect the component behavior; my concern is that consumers may be confused thinking or assuming setting timeZone would actually set the time zone for the dates being handled in the component; similarly to the odd utcOffset which doesn't do what you'd expect — do you think that's a valid concern? 🤔
| * Useful for | ||
| * @returns | ||
| */ | ||
| timeZoneCustomDisplayRender?: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think we could make this shorter too. The component is scoped only to display the time zone. The name seems unnecessarily long as there is no need to distinguish it from something else in the component. Maybe we could call it customRender ?
💭 That being said, maybe we could use children for the custom content? We can still pass along props like children({ nameDisplay }).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like having a render prop be just that, and I'm not a fan of children as function, but we have that pattern already in other components, and it makes sense here — I will use children 👍
| isDisabled?: boolean; | ||
| }; | ||
|
|
||
| // TODO rename to add eui prefix e.g. EuiTimeWindowButtons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, it's not relevant because it's a todo for another PR haha, I think I will keep it and remove it after I do the rename…
| timeZoneCustomDisplayRender: ({ nameDisplay }) => ( | ||
| <> | ||
| {nameDisplay} | ||
| <EuiButtonIcon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We should add an aria-label to showcase correct accessible usage.
| </p> | ||
| </EuiScreenReaderOnly> | ||
| </EuiForm> | ||
| <EuiTimeZoneDisplay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 One concern I have here in terms of Accessibility:
The time zone is added as regular content. It's not otherwise linked to the date at all. Most other content in the popover are interactive elements that force focus mode while the time zone is only perceivable via browse mode (not focusable). That could lead to it not being noticed potentially.
I'm wondering if we should provide the time zone information as additional information on the date input as well to provide full context.
// example: NVDA
// without linking the time zone
edit read only Nov 11, 2025 @ 09:27:16.792
// with linking the time zone via `aria-describedby`
edit read only UTC-8 (America/Los_Angeles) selected Nov 11, 2025 @ 09:25:01.562
// example: JAWS
// without linking the time zone
read only edit
Nov 11, 2025 @ 09:28:41.779
// with linking the time zone via `aria-describedby`
read only edit
Nov 11, 2025 @ 09:29:08.598
UTC-8 (America/Los_Angeles)
ℹ️ If the EuiFieldText is wrapped in EuiFormRow the linking has to happen via describedByIds on EuiFormRow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this but discard the idea, seeing the actual output makes me think it's worth doing it
question: do you think it'd be better to remove the "name" part? (I guess that's easy to do while keeping the visible text the same) the offset is what's important…
-edit read only UTC-8 (America/Los_Angeles) selected Nov 11, 2025 @ 09:25:01.562
+edit read only UTC-8 selected Nov 11, 2025 @ 09:25:01.562| render: (args) => <StatefulSuperDatePicker {...args} />, | ||
| }; | ||
|
|
||
| export const CustomTimeZoneDisplay: Story = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a story for the regular time zone as well? 🤔 (or enable it in an existing story at least to showcase it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do one of the two, that makes sense 👍
| roundUp, | ||
| labelPrefix, | ||
| timeZoneDisplay, | ||
| timeZoneCustomDisplayRender, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Unrelated to the marked line]:
I noticed that the prepend on the EuiFieldText is not linked to the input (code), meaning the input has no label (the same applies in other tabs).
We don't have to fix it here if you prefer keeping it scoped, but maybe you could add it at some point where it fits in while working on EuiSuperDatePicker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, if I don't do it here, I'll make sure to do it while working on EuiSuperDatePicker as you suggest
| }; | ||
|
|
||
| const customButton = ( | ||
| <EuiButtonIcon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add aria-label also here to provide a meaningful label.
Summary
Important
This PR merges into a feature branch
This adds time zone information to the date picker popovers in the
EuiSuperDatePicker. Passing the name of the time zone is required. The space where the time zone information is shown can be customized with a render function prop.Resolves https://github.com/elastic/eui-private/issues/440 🔒
Why are we making this change?
As part of a series of improvements to
EuiSuperDatePickerthat should have a positive immediate impact for users.Screenshots
Figma
Impact to users
🟢 No impact. Setting the
timeZoneDisplayprop is needed in order for the info to show. No logic in the component is affected.QA
📘 I'm open to feedback regarding:
timeZoneCustomDisplayRender) is the best approach for the custom contentGeneral checklist
Checked in both MacOS and Windows high contrast modes(emulate forced colors if you do not have access to a Windows machine.)Checked in mobile@defaultif default values are missing) and playground togglesIf applicable, added the breaking change issue label (and filled out the breaking change checklist)If the changes unblock an issue in a different repo, smoke tested carefully (see Testing EUI features in Kibana ahead of time)If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)